<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <my-father></my-father>
    </div>

    <!-- 父组件 -->
    <template id="father">
        <div>
            <h2>我是父组件--</h2>
            <my-son></my-son>
        </div>
    </template>

    <!-- 子组件 -->
    <template id="son">
        <div>
            <h5>我是子组件--</h5>
        </div>
    </template>


    <script src="./vue.js"></script>
    <script>
        // 子组件
        const Son = {
            template: "#son",
            beforeCreate() {
                console.log('我是子组件-beforeCreate--4')
            },
            created() {
                console.log('我是子组件-created--5')
            },
            beforeMount() {
                console.log('我是子组件-beforeMount--6')
            },
            mounted() {
                console.log('我是子组件-mounted--7')
            },
        }


        // 父组件
        const Father = {
            template: "#father",
            components: {
                "my-son": Son
            },
            beforeCreate() {
                console.log('我是父组件-beforeCreate--1')
            },
            created() {
                console.log('我是父组件-created--2')
            },
            beforeMount() {
                console.log('我是父组件-beforeMount--3')
            },
            mounted() {
                console.log('我是父组件-mounted--8')
            }
        }

        new Vue({
            el: "#app",
            // 注册组件
            // components: { 组件名称: 组件内容 }
            components: {
                "my-father": Father
            }
        })
    </script>
</body>

</html>